package Eyjafjalla.power;

import Eyjafjalla.patch.CloudPatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.utility.UseCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.powers.watcher.VigorPower;

public class SpurtOutPower extends AbstractEyjafjallaPower {
    public static final String POWER_ID = "eyjafjalla:SpurtOutPower";
    private static final PowerStrings powerStrings;

    public SpurtOutPower(AbstractCreature owner, int amount){
        this.name = powerStrings.NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        this.amount = amount;
        String path128 = "EyjafjallaResources/img/power/SpurtOutPower_84.png";
        String path48 = "EyjafjallaResources/img/power/SpurtOutPower_32.png";
        this.region128 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path128),0,0,84,84);
        this.region48 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path48),0,0,32,32);
        this.isTurnBased = true;
        this.type = PowerType.BUFF;
        this.enableExtraAmount = true;
        this.extraAmount = 0;
        this.updateDescription();
    }

    @Override
    public void atEndOfTurnPreEndTurnCards(boolean isPlayer) {
        if(extraAmount>0){
            this.flash();
            this.addToBot(new ApplyPowerAction(this.owner,this.owner,new VigorPower(this.owner,extraAmount),extraAmount));
            extraAmount = 0;
            updateDescription();
        }
    }

    @Override
    public void onUseCard(AbstractCard card, UseCardAction action) {
        if(CloudPatch.CloudField.isFire.get(card)){
            this.extraAmount+=this.amount;
            updateDescription();
        }
    }

    @Override
    public void updateDescription() {
        this.description = powerStrings.DESCRIPTIONS[0] + this.extraAmount + powerStrings.DESCRIPTIONS[1] + this.amount + powerStrings.DESCRIPTIONS[2];
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    }
}




